﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

/// <summary>
/// Summary description for Binding
/// </summary>

    public class Binding
    {
        #region "DropDownList"
        public static void BindShopType(DropDownList ddl, bool visibleTopItem, string valueTopItem, string textTopItem)
        {
            ddl.Items.Clear();

            DataTable dt = new DataTable();
            string strSql = "SELECT ShopType_ID, ShopType_Name FROM ShopType ORDER BY ShopType_ID ASC";
            DBConn oDBConn = new DBConn();
            oDBConn.OpenConnection();
            SqlDataAdapter oDataAdapter = new SqlDataAdapter(strSql, oDBConn.DBConnection);
            oDataAdapter.Fill(dt);
            oDataAdapter = null;
            oDBConn.Disconnect();

            ddl.DataSource = dt;
            ddl.DataTextField = "ShopType_Name";
            ddl.DataValueField = "ShopType_ID";
            ddl.DataBind();

            if (visibleTopItem)
            {
                ddl.Items.Insert(0, new ListItem(textTopItem, valueTopItem));
            }
        }

        public static void BindPackage(DropDownList ddl, bool visibleTopItem, string valueTopItem, string textTopItem)
        {
            ddl.Items.Clear();

            DataTable dt = new DataTable();
            string strSql = "SELECT Package_ID, Package_Name FROM Package ORDER BY Package_ID ASC";
            DBConn oDBConn = new DBConn();
            oDBConn.OpenConnection();
            SqlDataAdapter oDataAdapter = new SqlDataAdapter(strSql, oDBConn.DBConnection);
            oDataAdapter.Fill(dt);
            oDataAdapter = null;
            oDBConn.Disconnect();

            ddl.DataSource = dt;
            ddl.DataTextField = "Package_Name";
            ddl.DataValueField = "Package_ID";
            ddl.DataBind();

            if (visibleTopItem)
            {
                ddl.Items.Insert(0, new ListItem(textTopItem, valueTopItem));
            }
        }

        public static void BindUserType(DropDownList ddl, bool visibleTopItem, string valueTopItem, string textTopItem)
        {
            ddl.Items.Clear();

            DataTable dt = new DataTable();
            string strSql = "SELECT UserType_ID, UserType_Name FROM UserType WHERE UserType_ID <> 1 ORDER BY UserType_ID ASC";
            DBConn oDBConn = new DBConn();
            oDBConn.OpenConnection();
            SqlDataAdapter oDataAdapter = new SqlDataAdapter(strSql, oDBConn.DBConnection);
            oDataAdapter.Fill(dt);
            oDataAdapter = null;
            oDBConn.Disconnect();

            ddl.DataSource = dt;
            ddl.DataTextField = "UserType_Name";
            ddl.DataValueField = "UserType_ID";
            ddl.DataBind();

            if (visibleTopItem)
            {
                ddl.Items.Insert(0, new ListItem(textTopItem, valueTopItem));
            }
        }

        public static void BindStatus(DropDownList ddl, bool visibleTopItem, string valueTopItem, string textTopItem)
        {
            ddl.Items.Clear();

            ddl.Items.Insert(0, new ListItem("Inactive", "False"));
            ddl.Items.Insert(0, new ListItem("Active", "True"));

            if (visibleTopItem)
            {
                ddl.Items.Insert(0, new ListItem(textTopItem, valueTopItem));
            }
        }

        public static void BindTime(DropDownList ddl, bool visibleTopItem, string valueTopItem, string textTopItem)
        {
            ddl.Items.Clear();

            ddl.Items.Insert(0, new ListItem("1:00 AM", "01:00"));
            ddl.Items.Insert(0, new ListItem("2:00 AM", "02:00"));
            ddl.Items.Insert(0, new ListItem("3:00 AM", "03:00"));
            ddl.Items.Insert(0, new ListItem("4:00 AM", "04:00"));
            ddl.Items.Insert(0, new ListItem("5:00 AM", "05:00"));
            ddl.Items.Insert(0, new ListItem("6:00 AM", "06:00"));
            ddl.Items.Insert(0, new ListItem("7:00 AM", "07:00"));
            ddl.Items.Insert(0, new ListItem("8:00 AM", "08:00"));
            ddl.Items.Insert(0, new ListItem("9:00 AM", "09:00"));
            ddl.Items.Insert(0, new ListItem("10:00 AM", "10:00"));
            ddl.Items.Insert(0, new ListItem("11:00 AM", "11:00"));
            ddl.Items.Insert(0, new ListItem("12:00 AM", "12:00"));
            ddl.Items.Insert(0, new ListItem("1:00 PM", "13:00"));
            ddl.Items.Insert(0, new ListItem("2:00 PM", "14:00"));
            ddl.Items.Insert(0, new ListItem("3:00 PM", "15:00"));
            ddl.Items.Insert(0, new ListItem("4:00 PM", "16:00"));
            ddl.Items.Insert(0, new ListItem("5:00 PM", "17:00"));
            ddl.Items.Insert(0, new ListItem("6:00 PM", "18:00"));
            ddl.Items.Insert(0, new ListItem("7:00 PM", "19:00"));
            ddl.Items.Insert(0, new ListItem("8:00 PM", "20:00"));
            ddl.Items.Insert(0, new ListItem("9:00 PM", "21:00"));
            ddl.Items.Insert(0, new ListItem("10:00 PM", "22:00"));
            ddl.Items.Insert(0, new ListItem("11:00 PM", "23:00"));
            ddl.Items.Insert(0, new ListItem("12:00 PM", "00:00"));

            if (visibleTopItem)
            {
                ddl.Items.Insert(0, new ListItem(textTopItem, valueTopItem));
            }
        }
        #endregion
    }
